package com.uniview.feign.fallback;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.uniview.dto.RespDTO;
import org.apache.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * @Author lux
 * @date: 2019/12/11
 * @desc: 熔断异常
 */
@RestController
public class HystrixCommandController {
    @RequestMapping("/hystrixTimeout")
    public Mono<RespDTO> hystrixTimeout() {
        return Mono.just(RespDTO.onSuc("Network is busy. Try again later", HttpStatus.SC_BAD_GATEWAY));
    }
    @HystrixCommand(commandKey = "authHystrixCommand")
    public Mono<RespDTO> authHystrixCommand() {
        return Mono.just(RespDTO.onSuc("auth failed", HttpStatus.SC_BAD_GATEWAY));
    }
}
